define(function (require, exports, module) {
	
	var HandlerBars = require("handlebars");
	var detailsTpl = require("../assets/tpl/details.tpl");
	
    var instance = {
    	//初始化购物车
        initDetails: function (widget,data) {
        	var cartData = localStorage.getItem("cartData");
   			cartData = cartData?JSON.parse(cartData):{};
   			var tdata = null;
   			if(data.type == "service"){
    			var serviceItemData = widget.get("serviceItemData");
    			tdata = $.grep( serviceItemData, function(n,i){
    				  if(n.pk == data.pk){
    					  return n;
    				  }
    				})[0];
    		}else if(data.type == "goods"){
    			var goodsItemData = widget.get("goodsItemData");
    			tdata = $.grep( goodsItemData, function(n,i){
  				  if(n.pk == data.pk){
  					  return n;
  				  }
  				})[0];
    		}
   			console.log(tdata)
   			var html = HandlerBars.compile(detailsTpl)(tdata);
        	$("#details-center").html(html);
        }
    };
    module.exports = instance;
});
